package xyz.zcq.zcqrpc.protocol;

import lombok.Getter;

/**
 * 协议消息类型 枚举
 */
@Getter
public enum ProtocolMessageTypeEnum {
    REQUEST(0),
    RESPONSE(1),
    HEART_BEAT(2),
    OTHERS(3),
    ;

    private final int key;

    ProtocolMessageTypeEnum(int key) {
        this.key = key;
    }

    public static ProtocolMessageTypeEnum getByValue(int key) {
        for (ProtocolMessageTypeEnum pmt : ProtocolMessageTypeEnum.values()) {
            if (pmt.key == key) {
                return pmt;
            }
        }

        return null;
    }

}
